Large code revamp: renamed classes, moved algorithms into more appropriate classes.