Revert "Revert "Make setting parent bean faster""

This reverts commit 34f94a2beba53e9589d508414afa48ea7bf40934.
Revert "Revert "Also fixed unset().""

This reverts commit 3523e041d5b319c691867ae00e208ef8db3cd6d1.
Re-adding optimization and fixing issue #335.