Make API a bit more robust