Fixes, but this needs refactoring