Fix to bug #438 http://bugs.skysql.com/show_bug.cgi?id=438

Fixed some compiler warnings, added header includes, return values etc.