Final FYP Code (Could uses some commenting).