Configuration file support, moved some functionality to an external lib