Added Threading and sqlite structure