Fixed Sherm's suggestions, fixes issue #2.
Fixed Samin's suggestions, fixes issue #3.