Shifted code to relevant files

Encapsulation and removal of specific code from MainActivity