Add improvements from @CUBRID's implementation
5 files changed