Tons of code refactoring and some features added. GUI not updated yet.