Various bug fixes and updates