Added better version change handling. Some minor refactoring and clean up