Reorganize and comment code. Add function prototypes for alias and io redirection functions