Add comments and make some minor improvements