fixed bug for slots >= 5; added comments; refactored some names