Remove some unused code
Change the API a bit to make it cleaner