Fixed imports and a NullPointerException on baseUrl 

Fixed imports and a NullPointerException on baseUrl 
(and optimized a few lines)