Add dynamic method generation and change the API