Compyte2 rebase

This is a rebase of the compyte2 PR on top of the current master + a couple of small fixes for problems introduced by the rebase.