Some tweaks and bug fixes