added settings, cleaned up some code