Major restructure and settings logic tidy up