UGLY fixes, needs refactor