Debugging and minor fixes