working on a MAJOR refactoring (code is unstable).