removed debug logging
naming and minor stuff
damn you again, pseudo-code