Don't try to rewrite the whole system in one go. Move incrementally. You can start by creating your own UI that performs most common functions and uses existing system as a backend. This way you can automate what you need and work around bug. If it goes well then later you can gradually move to your own backend.