Database now has simpler syntax, but still doesn't close connections due to a problem with recursive queries getting messed up.