Separated theta calculation routine into new file.