Fixed compiler warnings and bug in code.