Context/parent fixes

Fixed bunch of bugs in context/parent assignment