Various fixes, start of restructure