various changes, bug fixes