Fixed some bugs. 
Also fixed warnings (Eclipse 4.3).