Bug Fixes

Fixed something like 6 bugs, also cleared out some of the compiler
warnings.