Added loader image and cleaned up code