Refactor for better design done

Same features as what is currently on master, but better design