Fixed bugs

Got alot of things working that broke with SQLite changeover and script
restructure. GPIO states work better now but I think the MCP just isnt
reporting output states correctly.