Updated changelog. Some refactoring. Fixed a couple of bugs with master re-ordering.