Fixed problems with entity manager closing, now all db scripts work