Cleanup and own endpoint

This PR improves the code in some points (such as not using global variables that were introduced by accident) and allowing the user to set a custom endpoint. I will probably add more features / improvements in the future.