Initial commit of the code-there are possibly bugs