Revert "Bug fixes for Database to save plan"

This reverts commit 5bfb461fb5882481cc36dd78f6174fdb2ab3c557.