Add debugging and remove uneeded code