Added offline capabilities. Need to clean code.