Lots of improvements and fixes. Ready for v3