[WIP] refactoring and options page improvements