code cleanup... moved inner class to own file as it was getting too large