Re-factored some classes and removed a few warnings