Database stuff. Might not even be right but its a start