Moved the logic of getting first element of class to util file

as titled. Also moved a couple more methods over.