Fixes #226.  Also fixed some compiler warnings.