Various bug fixes batch #1

Ref issue #21

See issue description to see what this PR addresses.

@jaypoulz 
Deserves brace... and possible reformatting of function call