Added comments and cleaned up the source code for android.