Final push. Now it is complete - needs testing and debugging