Fixed context/thread error

- Fixed context/thread error
- Workaround on recursive inserts

Signed-off-by: Darren Ehlers <me@darrenehlers.com>