Minor fixes and debugging improvements