Added variables for hash length, automatic cleanup and made more readable