Fixed many small issues and added docs on api