Various bug fixes batch #1

Ref issue #21