refactor some code and manage cygwin source