fix getControllingKey for php 5.3
patterns and fixing some things