Fixes build and removes unneccessary ends.