added code for loading frames from CSV, cleaned up code