Add comments and fix some warnings.