Cleaned all warnings and fixed errors. Untested.