tweaks and some bug fixes