Various bug fixes and ui improvements