Cleaned up code, fixed xs input array data issue and other minor things