added some links and cleaned up code