Various bugfixes and refactoring.
Added: First part of post-transfer logic.