Splitting up original code so it can work with end-user code easier.