Made some final touches on the code. Removed sysos and TODOs and improved some doc comments.