Add some phpdoc & code optimization