code re-organized into separate files

+ additional functionality