Debugging and several bug fixes.