Sorted out many things. Sorry this is a terrible commit message.