cleaned code, warnings, and added comments