Debugging and fixes