random tweaks and bug fixes