General Code update

Cleaned up code and removed a few lines used only in debugging