Made a lot of changes. Please pull and review but it works now