SYS-dbe-39a5.0: Replaced direct queries to `users` and `planets` tables with function calls. Also some fixes and changes