Merge housing code from Smaug 1.8b

The housing code had never been merged.