Can someone explain the rules for offside?

At the BC-Calgary game there were a couple of offside penalties charged against BC that I didn't understand.

On one, the BC defensive lineman entered the neutral zone (he moved his hand forward ~12 in) and then jumped back to give a yard before the ball was snapped. My understanding was this should not be a penalty yet the ref blew the play dead and automatically assessed 5 yards against BC. (If the player crossed the line of scrimmage, contacted a Calgary player, or made a Calgary player move, then as I understand this should be a penalty.) I was at the game so I didn't get to see a replay - did I miss something or did the ref just screw up?

The second one was again against BC, but this time on offense. This time, a Calgary defender jumped into the neutral zone and caused a BC O-lineman to release from his stance. My understanding is this is offside on the defense because the O-Lineman moved after the defender had entered the neutral zone. In the game, the penalty was assessed against BC. Again, did I miss something that appeared in replay on the tube or was this another ref screw up?

bad ref calls it sounds like, but the main fault lays on the BC players, they should know the rules by now and not take chances, and in the case of the BC oline, just don't move. Simply don't give the refs a reason to call you out, and if you take chances, be ready for the consequences.