bug fixes/code improvement