Implement relocations.

This still needs testing.