Currently iterating devices

Working on the function for iterating devices. Did some general cleanup
as well.