First real commit. Tested manually. Seems to work OK.