solution was rewritten, fo more details check hg repo :P