Tidy'd and bugfix