various bug fixes and image clearing