Restructuring for #177
Correcting code related to #152
Cleaned code
Restructured code
Reverting changes
Fixes #152 although the code should be generalized and cleaned up
Test for #152