Add shim support

Manual merge of #31, with tests added.