Added option to use a custom distribution function for the bunch
generation and latest corrections of Alex.