Corrected some debugging issues and a little clean up