Fix GCC 4.9.1 compatibility and other tweaks