working on mist integration and testing. some cleanup and refactoring also