Updates code to work with current modules, fixes tests.