Fix several compilation issues

See issues #2 and #3 for several comments on these changes.