more functionality and some cleanup