RF: add lib/ directory, move files around