major refactoring + add test program
TODO: module support