bug fixes & general improvements