Added more warnings, compiler options and improved code