copied over lime stuff from pipi-branch