First refactor done, made a separate class for the hash calculation.