Removed debugging print statements; fix bugs