Removed dead code and moved helper functions to Util.cs