src: improve ViewInit

This commit adds a bit of style and error handling to the ViewInit.

While at it, some code was refactorized.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>