patch libnih and refactor startup scripts