Critical fixes

First fully functional version.