Set Output Function Implementation and Small Enhancements

Implementation of set output function should be complete. It shouldn't need testing (it will definitely compile).

Also, added bonus changing of variable types so that we could optimize a little. :)
Forgot to turn TABs into spaces. :O