various bug fixes and additions