Fixed errors and some warnings, NEEDS CLEANING!