Almost impossible to read the final code, but I could squeeze far more than I expected and keep performance reasonable :)