Lots of updates to make it work. First functional version.