Fixed longstanding bug involving reference layer

should be ok now