Fixed plethora of warnings. Code cleanup.