major logic improvements, debugging, etc.