Removed debugging functions, fixxed a criticial bug