Fixed a bug with calculating safe positions

The bug was noted in numberten/zhenya_bot#20. Reason was using a wrong reference
as starting point for further checking for safe positions. Sadly this fix
introduces a massive runtime penalty. I am not sure about the reason for that.