Initial Commit

Some bugs fixed compared to the original version