Added code for calculating direction and retrieving GPS positions.