Rethink API to provide better flexibility and avoid run-time overhead