Add Javadocs and TODOs, fix some issues