code and debugging cleanup