Refactor and add some functionality, for more info, see the changelog