Resolve lots of bugs

See commits and referencing issues