Fix some compiler/runtime warnings
Merge pull request #192 from krf/work

Fix some compiler/runtime warnings