bug fixes and added functionality