Cleaned up the code, and got the onclick preference loading working.