integrate more libs and refactor codes