Improve the handling of minutes and fix bugs