Cleanup
Fixed bug with positioning in various cases. Refactor and optimize