Debugging and code clean up