Revert to working library and re-added features (project etc).

THIS IS WORKING CODE.
FROM HERE START TO MERGE WITH ENGINE
This is a revert to a working version. MERGE WITH ENGINE START HERE

Added project management and other working features.