I'm sorry, but the code does not have any indentation in sight. Just because you can read the code, doesn't mean that everybody else can. This is very hard to read and as an open-source easy-to-modify extension it should be easily read by almost anyone (not saying you have to dumb down the code, at the bare minimum, add some indentation, please).
Also my friend and I suspected usage of stolen code, because of the fucked up indentation, but take that with a grain of salt.