code refractor

- tear stuff from ui module to tools module
code refractor

all deleted functions are moved to tools module