Restructored parts of bayesact.py for optimization