Moved some code. small UX changes