Cleaned up source and removed most or all warnings