Reorganize code and make settings page look better