Refactor / bugfix prior to merge