Upgrade through2 to 0.5.1

Also do some refactoring and update dependencies