Added more functions, cleaned code up slightly more.