Fixes #3291 Thanks to @arpruss for reporting the bug, and suggesting the fix. Also, remove trailing whitespaces.