Bug fix. should be ready for main gui.