Fixes a regression in the code refactor and adds some more documentation.