Add first working code. Few know bugs and adjustments to be done are present though.