C# porting of Josef Jelinek's ACube