add configuration functions and documentation
improve documentation, use records, separate common functionality into
library