Issue 772

This set of changes fixes bugs with the friendly mines infrastructure, and makes things more maintainable.