Improved fibonacci function.