Prepared for Android.
Set up line selection and cleaned up code