Revert c370cb0..e3ca0fd

This rolls back to commit c370cb06b5a787af410aa7791d67e442c6ff9a2a.
fixed bugs made in the last commit