Removed bugs from the code and intergrated code with graphlab code.