Cleaned up some select code and extra functions