Rewrote change_dir.php

Attempted to fix Bug#1
Cleaned up functions.php