Fix compilation warnings

Fixes various compilation warnings. Includes fix for Issue #165.