Merged with the direct modifications from lc5 server.