Fix bugs, remove debug messages