Improving predictions code and adding --optimize option